# tests/conftest.py
import pytest
from selenium import webdriver
from selenium.webdriver.chrome.options import Options as ChromeOptions
from selenium.webdriver.firefox.options import Options as FirefoxOptions

def pytest_addoption(parser):
    parser.addoption("--hub-url", action="store", default="http://localhost:4444/wd/hub")

@pytest.fixture
def hub_url(request):
    return request.config.getoption("--hub-url")

@pytest.fixture
def chrome_driver(hub_url):
    options = ChromeOptions()
    options.add_argument('--no-sandbox')
    options.add_argument('--disable-dev-shm-usage')
    options.add_argument('--headless')
    options.add_argument('--disable-gpu')
    options.add_argument('--window-size=1920,1080')
    
    driver = webdriver.Remote(
        command_executor=hub_url,
        options=options
    )
    
    yield driver
    driver.quit()

@pytest.fixture
def firefox_driver(hub_url):
    options = FirefoxOptions()
    options.add_argument('--headless')
    
    driver = webdriver.Remote(
        command_executor=hub_url,
        options=options
    )
    
    yield driver
    driver.quit()